package MainThread;

import java.net.*;
import java.io.*;
import java.util.*;

/*
 *
 *1.将用户名改成ID
 *2.添加服务端界面
 *3.给添加好友实现功能
 *
 */
public class MyServer {
	public static final int EXIT = 0;
	public static final int LOGIN = 1;
	public static final int REG = 2;
	public static final int CHAT = 3;
	public static final int ACK = 4;
	public static final int FRIEND = 5;
	public static final int ADD = 6;
	public static final int UAD = 7;//用户上下线通知
	
	// 定义保存所有Socket的ArrayList
//	public static ArrayList<Socket> socketList = new ArrayList<>();
	public static Map<String,Socket> mapSocket = new HashMap<String, Socket>();
	
	// 以键值对形式缓存所有姓名对应的IP地址
	public static Map<String, String> mapIP = new HashMap<String, String>();

	public static void main(String[] args) throws IOException {
		ServerSocket ss = new ServerSocket(30000);
		while (true) {
			// 此行代码会阻塞，将一直等待别人的连接
			Socket s = ss.accept();
//			socketList.add(s);
			// 每当客户端连接后启动一条ServerThread线程为该客户端服务
			new Thread(new ServerThread(s)).start();
		}
	}
}